﻿using System;

namespace BaseSyntax.Values.StringTest.Format
{
	public class FormatOptions:ITest
	{
		public void Test()
		{
			var header = String.Format("{0,0}{1,6}{2,12}{1,8}{2,12}{3,14}\n",
				"City", "Year", "Population", "Change (%)");
			Console.WriteLine(header);
			
			var value = String.Format("{0,-10:C}", 34.66);         
			Console.WriteLine(value);
				
			Tuple<string, DateTime, int, DateTime, int>[] cities = 
			{ Tuple.Create("Los Angeles", new DateTime(1940, 1, 1), 1504277, 
					new DateTime(1950, 1, 1), 1970358),
				Tuple.Create("New York", new DateTime(1941, 1, 1), 7454995, 
					new DateTime(1950, 1, 1), 7891957),  
				Tuple.Create("Chicago", new DateTime(1942, 1, 1), 3396808, 
					new DateTime(1950, 1, 1), 3620962),  
				Tuple.Create("Detroit", new DateTime(1943, 1, 1), 1623452, 
					new DateTime(1950, 1, 1), 1849568) 
			};
			
			// {2,12:N0}{3,8:yyyy}{4,12:N0}{5,14:P1}
			foreach (var city in cities)
			{
				var output = String.Format("{0,-12}{1,8:y}",
					city.Item1, city.Item2, city.Item3, city.Item4, city.Item5,
					(city.Item5 - city.Item3) / (double) city.Item3);
				Console.WriteLine(output);
			}
		}
	}
}